import { customAlphabet as customAlphabetSync } from 'nanoid';
import { customAlphabet } from 'nanoid/async';

const codeNanoid = customAlphabet('0123456789');
const codeNanoidSync = customAlphabetSync('0123456789');
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789');
const nanoidSync = customAlphabetSync('abcdefghijklmnopqrstuvwxyz0123456789');

export const getCode = async (length: number = 6) => {
  return await codeNanoid(length);
};

export const getCodeSync = (length: number = 6) => {
  return codeNanoidSync(length);
};

export const getNanoid = async (length: number = 30) => {
  return await nanoid(length);
};

export const getNanoidSync = (length: number = 30) => {
  return nanoidSync(length);
};
